<template>
	<view class="skill">
		<u-swiper :list="swiperList" height="396"></u-swiper>
		<!-- <image class="banner"
			src="https://lvpaiqiche.oss-cn-hangzhou.aliyuncs.com/image/20230526/20230526165842_of23.png"
			mode="widthFix"></image> -->
		<view class="star">
			<button @click="handAll">
				<text style="padding-right: 10rpx;">我已学习本节，开始练习</text>
				<u-icon name="arrow-right"></u-icon>
			</button>
		</view>
		<view class="nav">
			<view class="nav-title">
				专项练习
			</view>
		</view>
		<view class="list">
			<view v-for="(item, index) in tableData" :key="item.id_" class="item flex align-center"
				@click="handStar(item)">
				<view class="icon">
					<image src="/static/skill/icon1.png" mode=""></image>
				</view>
				<view class="info">
					<view class="name u-line-1">{{ item.title_ }}</view>
					<view class="desc u-line-1">{{ item.content_ }}</view>
				</view>
				<view class="right">
					<u-icon name="arrow-right"></u-icon>
				</view>
				<view class="status" v-if="item.type_ == 1">判断题</view>
				<view class="status" v-if="item.type_ == 2">单选题</view>
				<view class="status" v-if="item.type_ == 3">多选题</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		doChapter,
		doBanner
	} from '@/api/skill.js'
	export default {
		data() {
			return {
				swiperList: [],
				id: '',
				tableData: [],
				city:''
			}
		},
		onLoad(options) {
			console.log(options)
			this.city = options.city
			this.id = options.id
			this.init()
			this.getBanner()
		},
		methods: {
			async getBanner() {
				const {
					data
				} = await doBanner()
				this.swiperList = data.map(el => {
					return el.image
				})
			},
			async init() {
				const {
					data
				} = await doChapter({
					city: this.city,
					skill_paper_id:this.id
				})
				this.tableData = data
			},
			handAll() {
				uni.navigateTo({
					url: `/pages/skill/answer?allid=${this.id}&type=all&city=${this.city}`
				})
			},
			handStar(e) {
				uni.navigateTo({
					url: `/pages/skill/answer?id=${e.id_}&city=${this.city}&allid=${this.id}`
				})
			}
		},
	}
</script>

<style lang="scss" scoped>
	.skill {
		.banner {
			width: 750rpx;
			height: auto;
		}

		.star {
			padding: 40rpx 52rpx 0 52rpx;

			button {
				margin: 0;
				background: linear-gradient(180deg, #03BE7A 0%, #03BE7A 100%);
				border-radius: 50rpx;
				height: 100rpx;
				display: flex;
				align-items: center;
				justify-content: center;
				font-size: 36rpx;
				font-family: PingFang SC-Medium, PingFang SC;
				font-weight: 500;
				color: #FFFFFF;

				&::after {
					border: none;
				}
			}
		}

		.nav {
			margin-top: 64rpx;
			padding: 0 24rpx;

			&-title {
				font-size: 36rpx;
				font-family: PingFang SC-Bold, PingFang SC;
				font-weight: bold;
				color: #333333;
				position: relative;
				padding-left: 18rpx;

				&::before {
					content: "";
					position: absolute;
					left: 0;
					top: 50%;
					transform: translateY(-50%);
					width: 6rpx;
					height: 34rpx;
					background: #36c269;
					border-radius: 4rpx;
				}
			}
		}

		.list {
			padding: 24rpx;

			.item {
				background-color: #FFFFFF;
				border-radius: 20rpx;
				padding: 48rpx 44rpx;
				position: relative;

				.status {
					position: absolute;
					right: 0;
					top: 0;
					font-size: 24rpx;
					font-family: PingFang SC-Regular, PingFang SC;
					font-weight: 400;
					color: #FFFFFF;
					background-color: #0683ff;
					padding: 8rpx 18rpx;
					border-radius: 0rpx 20rpx 0rpx 20rpx;
				}

				&:not(:first-child) {
					margin-top: 24rpx;
				}

				.icon {
					image {
						width: 100rpx;
						height: 100rpx;
					}
				}

				.info {
					flex: 1;
					width: 0;
					margin-left: 24px;

					.name {
						width: 394rpx;
						font-size: 32rpx;
						font-family: PingFang SC-Bold, PingFang SC;
						font-weight: bold;
						color: #000000;
					}

					.desc {
						width: 394rpx;
						margin-top: 10rpx;
						font-size: 26rpx;
						font-family: PingFang SC-Regular, PingFang SC;
						font-weight: 400;
						color: #999999;
					}
				}

				.right {
					color: #666666;
				}


			}
		}
	}
</style>